﻿
using System;

namespace LxCFD
{
    public class MassFluxBase : ScalarHeadBase
    {
        public double[] MassImbalance;//向外流出为正
        public double[] MassFlux;
        public float[] VelocityDirectionCorrection;
        public override void CheckCreate(FvZone zone)
        {
            base.CheckCreate(zone);
            LxTool.CheckCreateArray(ref MassImbalance, Cells.Length);
            LxTool.CheckCreateArray(ref MassFlux, Faces.Length);
            LxTool.CheckCreateArray(ref VelocityDirectionCorrection, Faces.Length);
        }
        public virtual void CalFaceMassFlux(int taskIndex)
        {
            throw new NotImplementedException();
        }
        public virtual void CalMassImbalance(int taskIndex)
        {
            calMassImbanlance(InnerIndex, taskIndex);
        }
        protected void setFaceFlux_0(IndexNumber indexNumber, int taskIndex)
        {
            indexNumber.FaceIDs.GetSeg(out int i1, out int endp1, taskIndex);
            for (; i1 < endp1; i1++)
            {
                MassFlux[i1] = 0;
            }
        }
        protected void calMassImbanlance(IndexNumber indexNumber, int taskIndex)
        {
            indexNumber.CellIDs.GetSeg(out int i1, out int endp1, taskIndex);
            for (; i1 < endp1; i1++)
            {
                MassImbalance[i1] = Cells[i1].CalIfOwnerAddElseMunus(MassFlux);
            }
        }
        protected void setMassImbanlance_0(IndexNumber indexNumber, int taskIndex)
        {
            indexNumber.CellIDs.GetSeg(out int i1, out int endp1, taskIndex);
            for (; i1 < endp1; i1++)
            {
                MassImbalance[i1] = 0;
            }
        }

    }
}

